using MicroMsg.Common.Event;
using MicroMsg.Common.Utils;
using MicroMsg.Manager;
using MicroMsg.Plugin.Sns.Scene;
using MicroMsg.Resource.@string;
using MicroMsg.Storage;
using MicroMsg.UI.Page;
using MicroMsg.UI.Util;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
namespace MicroMsg.UI.UserContrl
{
	public class TimelineDetailCtrl : UserControl
	{
		private enum MediaCtrlKind
		{
			None,
			Photos,
			AppMsg
		}
		private const string TAG = "TimelineDetailCtrl";
		private const double cDNickNameMaxWidth = 350.0;
		private const int cNMaxCntInLine = 5;
		private const int MAX_ELEMENT_NUM = 400;
		public int mNItemId;
		public static int sNItemCnt = 0;
		public static DependencyProperty ItemObjectProperty = DependencyProperty.Register("ItemObject", typeof(object), typeof(TimelineDetailCtrl), new PropertyMetadata(null, new PropertyChangedCallback(TimelineDetailCtrl.OnItemObjectPropertyChanged)));
		private bool mBIsFirstLoaded = true;
		private EventWatcher mWatchxxx;
		private object mObjectWatcher;
		public MMStandardUIEvent mCmtItemClickedDlg;
		private TimelineDetailCtrl.MediaCtrlKind mCurMediaCtrlKind;
		private int cNMaxCmtCnt = 5;
		private bool mBHasCmt;
		private bool mBHasLike;
		private string mStrIntro;
		private List<SnsComment> mListDefaultCmts;
		private static List<TimelineDetailCtrl> sTimelineDetailCtrl = new List<TimelineDetailCtrl>();
		private static Dictionary<int, TimelineDetailCtrl> sDictUsedItems = new Dictionary<int, TimelineDetailCtrl>();
		private static List<TimelineDetailCtrl> sTimelineDetailCtrlUsed = new List<TimelineDetailCtrl>();
		internal Grid btnLayoutRoot;
		internal UserHeadCtrl imgHead;
		internal NickNameButton txtNickName;
		internal TextBlock txtAction;
		internal RichTextBox richTxtIntro;
		internal Paragraph paraIntro;
		internal Grid containerlPics;
		internal EmojiTextEx txtSendTo;
		internal StackPanel containerExInfo;
		internal TextBlock txtTime;
		internal TextBlock txtLoc;
		internal ClickableLayout btnVisibility;
		internal Image imgVisiRangeTag;
		internal ClickableLayout btnDelete;
		internal StackPanel panelLikeAndCmt;
		internal Grid gridCmtLikeBack;
		internal StackPanel panelLike;
		internal RichTextBox mRichTxtLikes;
		internal Paragraph mParaLikes;
		internal Canvas canvasCmtAndLikeLine;
		internal StackPanel panelCmts;
		internal StackPanel containerComments;
		internal TextBlock txtCantCmt;
		internal ClickEffectGrid panelResend;
		internal TextBlock txtResend;
		private bool _contentLoaded;
		public object ItemObject
		{
			get
			{
				return base.GetValue(TimelineDetailCtrl.ItemObjectProperty);
			}
			set
			{
				base.SetValue(TimelineDetailCtrl.ItemObjectProperty, value);
			}
		}
		public TimelineDetailCtrl()
		{
			ShowObjectInMemory.AddOneObjectRecord(this);
			this.mNItemId = TimelineDetailCtrl.sNItemCnt++;
			this.InitializeComponent();
			this.txtNickName.txtNickName.FontSize = 28.0;
			base.add_Loaded(new RoutedEventHandler(this.Control_Loaded));
			base.add_Unloaded(new RoutedEventHandler(this.Control_Unloaded));
		}
		~TimelineDetailCtrl()
		{
			ShowObjectInMemory.RemoveOneObjectRecord(this);
		}
		private static void OnItemObjectPropertyChanged(DependencyObject dependencyObject_0, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs_0)
		{
			if (dependencyPropertyChangedEventArgs_0.get_Property() == TimelineDetailCtrl.ItemObjectProperty)
			{
				(dependencyObject_0 as TimelineDetailCtrl).ItemObjectPropertyChanged(dependencyPropertyChangedEventArgs_0);
			}
		}
		private void ItemObjectPropertyChanged(DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs_0)
		{
			if (dependencyPropertyChangedEventArgs_0.get_OldValue() != dependencyPropertyChangedEventArgs_0.get_NewValue())
			{
				this.clearUi();
			}
		}
		private void Control_Loaded(object sender, RoutedEventArgs e)
		{
		}
		private void Control_Unloaded(object sender, RoutedEventArgs e)
		{
		}
		private void registerEvent()
		{
			if (this.mWatchxxx == null)
			{
				this.mWatchxxx = new EventWatcher(this, null, new EventHandlerDelegate(this.Onxxx));
				EventCenter.registerEventWatcher(EventConst.ON_STORAGE_CONTACT_ADD, this.mWatchxxx);
			}
		}
		private void unRegisterEvent()
		{
			if (this.mWatchxxx != null)
			{
				EventCenter.removeEventWatcher(EventConst.ON_STORAGE_CONTACT_ADD, this.mWatchxxx);
				this.mWatchxxx = null;
			}
		}
		private void Onxxx(EventWatcher watcher, BaseEventArgs evtArgs)
		{
			if (evtArgs == null)
			{
				return;
			}
		}
		private void panelResend_mClicked(object sender, object args)
		{
			MMMessageBox mMMessageBox = MMMessageBox.Show(strings.Album_ReSendConfirm, "", true, strings.COM_Confirm, strings.COM_Cancel);
			mMMessageBox.ReturnEvent = new DlgReturnEvent(this.ResendDialogReturn);
		}
		public void ResendDialogReturn(DlgReturnEventArg dlgReturnEventArg_0)
		{
			int userClickResult = MMMessageBox.GetUserClickResult(dlgReturnEventArg_0);
			int num = userClickResult;
			if (num != 0)
			{
				return;
			}
			SnsPostService.resendAndPost((this.ItemObject as SnsInfo).nLocalID);
			this.btnDelete.set_Visibility(1);
			this.panelResend.set_Visibility(1);
			BasePage rootPage = ToolFunction.GetRootPage();
			if (rootPage != null)
			{
				rootPage.GoBack();
			}
		}
		private void btnDelete_Click(object sender, RoutedEventArgs e)
		{
			MMMessageBox mMMessageBox = MMMessageBox.Show(strings.Album_DeleteConfirmTimeline, "", true, strings.COM_Confirm, strings.COM_Cancel);
			mMMessageBox.ReturnEvent = new DlgReturnEvent(this.DeleteItemDialogReturn);
		}
		public void DeleteItemDialogReturn(DlgReturnEventArg dlgReturnEventArg_0)
		{
			int userClickResult = MMMessageBox.GetUserClickResult(dlgReturnEventArg_0);
			int num = userClickResult;
			if (num != 0)
			{
				return;
			}
			SnsInfo snsInfo = this.ItemObject as SnsInfo;
			if (snsInfo == null)
			{
				return;
			}
			SnsInfoMgr.deleteSnsObject(snsInfo.nObjectID, true);
			BasePage rootPage = ToolFunction.GetRootPage();
			if (rootPage != null)
			{
				rootPage.GoBack();
			}
		}
		private void btnVisibility_Click(object sender, RoutedEventArgs e)
		{
			SnsInfo snsInfo = this.ItemObject as SnsInfo;
			if (snsInfo != null && snsInfo.groupList != null)
			{
				ShowVisiGroupsContactsPage.GotoThisPage(snsInfo.groupList.list);
				return;
			}
		}
		public void RefreshItem()
		{
			if (this.ItemObject == null || !(this.ItemObject is SnsInfo))
			{
				return;
			}
			this.btnVisibility.set_Visibility(1);
			this.txtAction.set_Visibility(1);
			this.txtNickName.set_MaxWidth(350.0);
			this.txtNickName.txtNickName.set_MaxWidth(350.0);
			SnsInfo snsInfo = this.ItemObject as SnsInfo;
			this.txtNickName.ItemObject = snsInfo.strUserName;
			this.imgHead.ItemObject = snsInfo.strUserName;
			this.setWithList(snsInfo);
			this.setLikeList(snsInfo);
			if (snsInfo.nStatus == 4)
			{
				this.btnDelete.set_Visibility(0);
				this.panelResend.set_Visibility(0);
			}
			else
			{
				this.btnDelete.set_Visibility(1);
				this.panelResend.set_Visibility(1);
			}
			TimeLineObject timeLine = SnsInfoMgr.getTimeLine(snsInfo);
			if (timeLine == null)
			{
				TimeLineObject.dumpXmlData(snsInfo.bytesObjectDesc);
				this.containerlPics.set_Visibility(1);
				return;
			}
			if (timeLine.nPrivate == 1)
			{
				this.txtCantCmt.set_Visibility(0);
			}
			else
			{
				this.txtCantCmt.set_Visibility(1);
			}
			this.containerlPics.set_Visibility(0);
			this.setPicsIntro(timeLine.strContentDesc);
			this.displayMediaInfo(snsInfo, timeLine);
			if (snsInfo.commentList != null && snsInfo.commentList.list != null)
			{
				this.setComments(snsInfo.commentList.list);
			}
			else
			{
				this.setComments(null);
			}
			if (this.mBHasCmt && this.mBHasLike)
			{
				this.canvasCmtAndLikeLine.set_Visibility(0);
			}
			else
			{
				this.canvasCmtAndLikeLine.set_Visibility(1);
			}
			if (!this.mBHasCmt && !this.mBHasLike)
			{
				this.panelLikeAndCmt.set_Visibility(1);
			}
			else
			{
				this.panelLikeAndCmt.set_Visibility(0);
			}
			if (this.mBHasCmt)
			{
				this.panelCmts.set_Visibility(0);
			}
			else
			{
				this.panelCmts.set_Visibility(1);
			}
			if (timeLine != null && timeLine.content != null)
			{
				this.containerlPics.set_Visibility(0);
				this.disAction(timeLine.content);
			}
			else
			{
				this.containerlPics.set_Visibility(1);
			}
			base.UpdateLayout();
		}
		private void clearUi()
		{
			this.imgHead.ItemObject = null;
			this.txtNickName.ItemObject = null;
		}
		private void disAction(ContentObject conobj)
		{
			if (conobj == null)
			{
				return;
			}
			switch (conobj.nStyle)
			{
			case 0:
				this.containerlPics.set_Visibility(1);
				this.txtAction.set_Visibility(1);
				break;
			case 1:
				this.txtAction.set_Visibility(1);
				this.setDisplayCtrl(TimelineDetailCtrl.MediaCtrlKind.Photos);
				this.disContentAsPhoto(conobj.mediaList);
				break;
			case 2:
				this.containerlPics.set_Visibility(1);
				this.txtAction.set_Visibility(1);
				break;
			case 3:
				this.txtAction.set_Text(strings.WC_Action_SHARE_FEED);
				this.txtAction.set_Visibility(0);
				this.setDisplayCtrl(TimelineDetailCtrl.MediaCtrlKind.AppMsg);
				this.disContentAsAppmsg(conobj);
				break;
			case 4:
				this.txtAction.set_Text(strings.WC_Action_SHARE_MUSIC);
				this.txtAction.set_Visibility(0);
				this.setDisplayCtrl(TimelineDetailCtrl.MediaCtrlKind.AppMsg);
				this.disContentAsAppmsg(conobj);
				break;
			case 5:
				this.txtAction.set_Text(strings.WC_Action_SHARE_VIDEO);
				this.txtAction.set_Visibility(0);
				this.containerlPics.set_Visibility(1);
				break;
			case 6:
				this.containerlPics.set_Visibility(1);
				break;
			case 7:
				this.txtAction.set_Text(strings.WC_Action_CHANGE_BACKGROUND);
				this.txtAction.set_Visibility(0);
				this.setDisplayCtrl(TimelineDetailCtrl.MediaCtrlKind.Photos);
				this.disContentAsPhoto(conobj.mediaList);
				break;
			case 8:
				this.containerlPics.set_Visibility(1);
				break;
			default:
				this.containerlPics.set_Visibility(1);
				this.txtAction.set_Visibility(1);
				break;
			}
			if (this.txtAction.get_Visibility() == null)
			{
				this.txtAction.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
				double width = this.txtAction.get_DesiredSize().get_Width();
				this.txtNickName.txtNickName.InvalidateMeasure();
				this.txtNickName.txtNickName.set_MaxWidth(350.0 - width - 10.0);
				this.txtNickName.set_MaxWidth(350.0 - width - 10.0);
			}
		}
		private void setDisplayCtrl(TimelineDetailCtrl.MediaCtrlKind ctrlKind)
		{
			if (this.mCurMediaCtrlKind == ctrlKind)
			{
				return;
			}
			this.recycleCurMediaCtrl();
			switch (ctrlKind)
			{
			case TimelineDetailCtrl.MediaCtrlKind.Photos:
			{
				CirclePagePicsCtrl oneItem = CirclePagePicsCtrl.GetOneItem();
				if (oneItem != null)
				{
					this.containerlPics.get_Children().Add(oneItem);
				}
				break;
			}
			case TimelineDetailCtrl.MediaCtrlKind.AppMsg:
			{
				AppMsgDisplayer oneItem2 = AppMsgDisplayer.GetOneItem();
				if (oneItem2 != null)
				{
					this.containerlPics.get_Children().Add(oneItem2);
				}
				break;
			}
			}
			this.mCurMediaCtrlKind = ctrlKind;
		}
		private UIElement getCurMediaCtrl()
		{
			if (this.containerlPics.get_Children().get_Count() == 0)
			{
				return null;
			}
			return this.containerlPics.get_Children().get_Item(0);
		}
		private void recycleCurMediaCtrl()
		{
			if (this.containerlPics.get_Children().get_Count() == 0)
			{
				this.mCurMediaCtrlKind = TimelineDetailCtrl.MediaCtrlKind.None;
				return;
			}
			switch (this.mCurMediaCtrlKind)
			{
			case TimelineDetailCtrl.MediaCtrlKind.Photos:
			{
				CirclePagePicsCtrl circlePagePicsCtrl = this.containerlPics.get_Children().get_Item(0) as CirclePagePicsCtrl;
				this.containerlPics.get_Children().Clear();
				if (circlePagePicsCtrl != null)
				{
					CirclePagePicsCtrl.PushOneItem(circlePagePicsCtrl);
				}
				break;
			}
			case TimelineDetailCtrl.MediaCtrlKind.AppMsg:
			{
				AppMsgDisplayer appMsgDisplayer = this.getCurMediaCtrl() as AppMsgDisplayer;
				this.containerlPics.get_Children().Clear();
				if (appMsgDisplayer != null)
				{
					AppMsgDisplayer.PushOneItem(appMsgDisplayer);
				}
				break;
			}
			}
			this.mCurMediaCtrlKind = TimelineDetailCtrl.MediaCtrlKind.None;
		}
		private void disContentAsPhoto(List<TloMedia> listMediaInfo)
		{
			if (listMediaInfo == null || listMediaInfo.get_Count() == 0)
			{
				this.containerlPics.set_Visibility(1);
				return;
			}
			this.containerlPics.set_Visibility(0);
			this.setDisplayCtrl(TimelineDetailCtrl.MediaCtrlKind.Photos);
			CirclePagePicsCtrl circlePagePicsCtrl = this.getCurMediaCtrl() as CirclePagePicsCtrl;
			if (listMediaInfo == null)
			{
				circlePagePicsCtrl.ItemObject = new List<TloMedia>();
				return;
			}
			circlePagePicsCtrl.ItemObject = listMediaInfo;
		}
		private void disContentAsAppmsg(ContentObject conobj)
		{
			this.setDisplayCtrl(TimelineDetailCtrl.MediaCtrlKind.AppMsg);
			AppMsgDisplayer appMsgDisplayer = this.getCurMediaCtrl() as AppMsgDisplayer;
			if (appMsgDisplayer == null)
			{
				return;
			}
			appMsgDisplayer.ItemObject = conobj;
		}
		private void setComments(List<SnsComment> listComts)
		{
			if (this.mListDefaultCmts != null)
			{
				listComts = Enumerable.ToList<SnsComment>(Enumerable.Where<SnsComment>(this.mListDefaultCmts, (SnsComment snsComment_0) => snsComment_0.nType == 3u));
			}
			if (listComts != null && listComts.get_Count() != 0)
			{
				this.mBHasCmt = true;
				this.setCmtsItemCnt(listComts.get_Count());
				int num = 0;
				while (num < listComts.get_Count() && num < this.containerComments.get_Children().get_Count())
				{
					TLDetailCmtsItem tLDetailCmtsItem = this.containerComments.get_Children().get_Item(num) as TLDetailCmtsItem;
					if (tLDetailCmtsItem != null)
					{
						if (num != this.containerComments.get_Children().get_Count() - 1)
						{
							tLDetailCmtsItem.canvasCmtsLine.set_Visibility(0);
						}
						else
						{
							tLDetailCmtsItem.canvasCmtsLine.set_Visibility(1);
						}
						tLDetailCmtsItem.ItemObject = listComts.get_Item(num);
					}
					num++;
				}
				return;
			}
			this.setCmtsItemCnt(0);
			this.mBHasCmt = false;
		}
		private void setCmtsItemCnt(int nCmtsCnt)
		{
			if (nCmtsCnt < 0)
			{
				nCmtsCnt = 0;
			}
			if (nCmtsCnt > this.containerComments.get_Children().get_Count())
			{
				int num = nCmtsCnt - this.containerComments.get_Children().get_Count();
				for (int i = 0; i < num; i++)
				{
					TLDetailCmtsItem oneItem = TLDetailCmtsItem.GetOneItem();
					if (oneItem != null)
					{
						oneItem.mClickDlg = new MMStandardUIEvent(this.cmtItemClicked);
						this.containerComments.get_Children().Add(oneItem);
					}
				}
				return;
			}
			if (nCmtsCnt < this.containerComments.get_Children().get_Count())
			{
				int num2 = this.containerComments.get_Children().get_Count() - nCmtsCnt;
				for (int j = 0; j < num2; j++)
				{
					TLDetailCmtsItem tLDetailCmtsItem = Enumerable.First<UIElement>(this.containerComments.get_Children()) as TLDetailCmtsItem;
					this.containerComments.get_Children().RemoveAt(0);
					tLDetailCmtsItem.mClickDlg = null;
					TLDetailCmtsItem.PushOneItem(tLDetailCmtsItem);
				}
			}
		}
		private void cmtItemClicked(object sender, object object_0)
		{
			if (this.mCmtItemClickedDlg != null)
			{
				this.mCmtItemClickedDlg(sender, object_0);
			}
		}
		private void setWithList(SnsInfo snsInfo)
		{
			this.txtSendTo.Text = "";
			this.txtSendTo.set_Visibility(1);
			if (snsInfo == null || snsInfo.nWithUserCount == 0 || snsInfo.withList == null || snsInfo.withList.list == null || snsInfo.withList.list.get_Count() == 0)
			{
				return;
			}
			if (AccountMgr.isAccountOwner(snsInfo.strUserName))
			{
				this.setRemindFriendText(snsInfo);
				return;
			}
			this.setRemindMeText(snsInfo);
		}
		private void setRemindMeText(SnsInfo snsInfo)
		{
			using (List<SnsComment>.Enumerator enumerator = snsInfo.withList.list.GetEnumerator())
			{
				while (enumerator.MoveNext())
				{
					SnsComment current = enumerator.get_Current();
					if (current.strUserName == AccountMgr.strUsrName)
					{
						this.txtSendTo.Text = strings.Album_With_Me;
						this.txtSendTo.set_Visibility(0);
						break;
					}
				}
			}
		}
		private void setRemindFriendText(SnsInfo snsInfo)
		{
			List<SnsComment> list = snsInfo.withList.list;
			string text = strings.Album_Remind_Who;
			int num = 0;
			using (List<SnsComment>.Enumerator enumerator = list.GetEnumerator())
			{
				while (enumerator.MoveNext())
				{
					SnsComment current = enumerator.get_Current();
					if (current != null)
					{
						if (num != 0)
						{
							text += ",";
						}
						text += ContactHelper.getDisplayName(current.strUserName, current.strNickName);
						num++;
					}
				}
			}
			this.txtSendTo.Text = text;
			this.txtSendTo.set_Visibility(0);
		}
		private void setLikeList(SnsInfo snsInfo)
		{
			List<SnsComment> list = new List<SnsComment>();
			if (this.mListDefaultCmts != null)
			{
				list = Enumerable.ToList<SnsComment>(Enumerable.Where<SnsComment>(this.mListDefaultCmts, (SnsComment snsComment_0) => snsComment_0.nType == 5u || snsComment_0.nType == 1u));
			}
			else
			{
				list = ((snsInfo.likeList == null) ? null : snsInfo.likeList.list);
			}
			if (list != null && list.get_Count() != 0)
			{
				this.mBHasLike = true;
				int count = list.get_Count();
				this.setLikeCnt(count);
				this.setLikeListToPara(list);
				return;
			}
			this.setLikeCnt(0);
			this.mBHasLike = false;
		}
		private void setLikeCnt(int nLikeCnt)
		{
			if (nLikeCnt <= 0)
			{
				this.panelLike.set_Visibility(1);
				return;
			}
			this.panelLike.set_Visibility(0);
			this.setLikeParaCnt(nLikeCnt);
		}
		private void setLikeParaCnt(int nCnt)
		{
			if (nCnt < 0)
			{
				nCnt = 0;
			}
			if (this.mParaLikes.get_Inlines().get_Count() > nCnt)
			{
				while (this.mParaLikes.get_Inlines().get_Count() > nCnt)
				{
					InlineUIContainer inlineUIContainer = Enumerable.Last<Inline>(this.mParaLikes.get_Inlines()) as InlineUIContainer;
					if (inlineUIContainer != null)
					{
						UserHeadCtrl userHeadCtrl = inlineUIContainer.get_Child() as UserHeadCtrl;
						inlineUIContainer.set_Child(null);
						if (userHeadCtrl != null)
						{
							UserHeadCtrl.PushOneItem(userHeadCtrl);
						}
					}
					this.mParaLikes.get_Inlines().RemoveAt(this.mParaLikes.get_Inlines().get_Count() - 1);
				}
				return;
			}
			int i = nCnt - this.mParaLikes.get_Inlines().get_Count();
			while (i > 0)
			{
				i--;
				this.mParaLikes.get_Inlines().Insert(0, this.getLikeNickInline(null));
			}
		}
		private InlineUIContainer getLikeNickInline(string strUserName = null)
		{
			InlineUIContainer inlineUIContainer = new InlineUIContainer();
			UserHeadCtrl oneItem = UserHeadCtrl.GetOneItem();
			oneItem.set_Height(58.0);
			oneItem.set_Width(58.0);
			oneItem.set_Margin(new Thickness(3.5, 3.5, 3.5, 3.5));
			if (strUserName != null)
			{
				oneItem.ItemObject = strUserName;
			}
			inlineUIContainer.set_Child(oneItem);
			return inlineUIContainer;
		}
		private bool containsLike(string strUser)
		{
			bool result;
			using (IEnumerator<Inline> enumerator = this.mParaLikes.get_Inlines().GetEnumerator())
			{
				while (enumerator.MoveNext())
				{
					Inline current = enumerator.get_Current();
					InlineUIContainer inlineUIContainer = current as InlineUIContainer;
					if (inlineUIContainer != null)
					{
						UserHeadCtrl userHeadCtrl = inlineUIContainer.get_Child() as UserHeadCtrl;
						if (userHeadCtrl != null && userHeadCtrl.ItemObject == strUser)
						{
							result = true;
							return result;
						}
					}
				}
				return false;
			}
			return result;
		}
		private void setLikeListToPara(List<SnsComment> likeList)
		{
			if (likeList != null && likeList.get_Count() != 0)
			{
				int count = likeList.get_Count();
				List<string> list = new List<string>();
				for (int i = 0; i < likeList.get_Count(); i++)
				{
					if (i >= this.mParaLikes.get_Inlines().get_Count())
					{
						return;
					}
					SnsComment snsComment = likeList.get_Item(count - 1 - i);
					InlineUIContainer inlineUIContainer = this.mParaLikes.get_Inlines().get_Item(i) as InlineUIContainer;
					if (inlineUIContainer != null)
					{
						UserHeadCtrl userHeadCtrl = inlineUIContainer.get_Child() as UserHeadCtrl;
						if (userHeadCtrl != null)
						{
							if (list.Contains(snsComment.strUserName))
							{
								userHeadCtrl.set_Visibility(1);
							}
							else
							{
								userHeadCtrl.set_Visibility(0);
								userHeadCtrl.ItemObject = snsComment.strUserName;
								list.Add(snsComment.strUserName);
							}
						}
					}
				}
				return;
			}
		}
		private void displayMediaInfo(SnsInfo snsInfo, TimeLineObject timeLineObj)
		{
			if (snsInfo == null)
			{
				return;
			}
			string text = Util.formatTimeInChatMsg((long)((ulong)snsInfo.nCreateTime));
			if (string.IsNullOrEmpty(text))
			{
				this.txtTime.set_Visibility(1);
			}
			else
			{
				this.txtTime.set_Text(text);
				this.txtTime.set_Visibility(0);
			}
			if (SnsGroupMgr.IsNeedShowVisiIcon(snsInfo))
			{
				this.btnVisibility.set_Visibility(base.get_Visibility());
				if (this.imgVisiRangeTag.get_Source() == null)
				{
					this.imgVisiRangeTag.set_Source(ToolFunction.GetImgFromContentSource(R.theme.Sns_ImgPath_multilike_icon));
				}
			}
			string text2 = null;
			if (timeLineObj.tloLocation_0 != null)
			{
				text2 = timeLineObj.tloLocation_0.strCity;
			}
			if (!string.IsNullOrWhiteSpace(text2))
			{
				this.txtLoc.set_Text(text2);
				return;
			}
			this.txtLoc.set_Text(null);
		}
		private void setPicsIntro(string strContent)
		{
			if (string.IsNullOrEmpty(strContent))
			{
				this.richTxtIntro.set_Visibility(1);
			}
			else
			{
				this.richTxtIntro.set_Visibility(0);
			}
			if (this.mStrIntro == strContent)
			{
				return;
			}
			this.mStrIntro = strContent;
			this.paraIntro.get_Inlines().Clear();
			if (string.IsNullOrEmpty(this.mStrIntro))
			{
				return;
			}
			List<InLineResult> inLineResult = RichTextHelper.GetInLineResult(strContent, (int)this.paraIntro.get_FontSize(), null, null);
			new InlineUIContainer();
			int num = 0;
			using (List<InLineResult>.Enumerator enumerator = inLineResult.GetEnumerator())
			{
				while (enumerator.MoveNext())
				{
					InLineResult current = enumerator.get_Current();
					if (current.mInline != null)
					{
						num++;
						this.paraIntro.get_Inlines().Add(current.mInline);
						if (num >= 400)
						{
							Run run = new Run();
							run.set_Text("......");
							this.paraIntro.get_Inlines().Add(run);
							break;
						}
					}
				}
			}
		}
		public void SetDefaultCmts(List<SnsComment> listCmts)
		{
			this.mListDefaultCmts = listCmts;
		}
		public void AddLike(SnsComment snsComment_0)
		{
			if (snsComment_0 == null || snsComment_0.strUserName == null)
			{
				return;
			}
			if (!this.containsLike(snsComment_0.strUserName))
			{
				this.mParaLikes.get_Inlines().Insert(0, this.getLikeNickInline(snsComment_0.strUserName));
			}
			this.panelLike.set_Visibility(0);
			this.mBHasLike = true;
			if (this.mBHasCmt && this.mBHasLike)
			{
				this.canvasCmtAndLikeLine.set_Visibility(0);
				return;
			}
			this.canvasCmtAndLikeLine.set_Visibility(1);
		}
		public void AddComment(SnsComment snsComment_0)
		{
			if (snsComment_0 == null || snsComment_0.strUserName == null)
			{
				return;
			}
			if (this.containerComments.get_Children().get_Count() != 0)
			{
				TLDetailCmtsItem tLDetailCmtsItem = this.containerComments.get_Children().get_Item(this.containerComments.get_Children().get_Count() - 1) as TLDetailCmtsItem;
				if (tLDetailCmtsItem != null)
				{
					tLDetailCmtsItem.canvasCmtsLine.set_Visibility(0);
				}
			}
			TLDetailCmtsItem oneItem = TLDetailCmtsItem.GetOneItem();
			oneItem.ItemObject = snsComment_0;
			oneItem.canvasCmtsLine.set_Visibility(1);
			oneItem.mClickDlg = new MMStandardUIEvent(this.cmtItemClicked);
			this.containerComments.get_Children().Add(oneItem);
			this.panelCmts.set_Visibility(0);
			this.mBHasCmt = true;
			if (this.mBHasCmt && this.mBHasLike)
			{
				this.canvasCmtAndLikeLine.set_Visibility(0);
				return;
			}
			this.canvasCmtAndLikeLine.set_Visibility(1);
		}
		public void DelComment(int nCmtId)
		{
			for (int i = 0; i < this.containerComments.get_Children().get_Count(); i++)
			{
				TLDetailCmtsItem tLDetailCmtsItem = this.containerComments.get_Children().get_Item(i) as TLDetailCmtsItem;
				if (tLDetailCmtsItem != null && tLDetailCmtsItem.ItemObject != null && nCmtId == tLDetailCmtsItem.ItemObject.nCommentId)
				{
					if (1 == this.containerComments.get_Children().get_Count())
					{
						this.panelCmts.set_Visibility(1);
						this.mBHasCmt = false;
					}
					else
					{
						if (i == this.containerComments.get_Children().get_Count() - 1)
						{
							TLDetailCmtsItem tLDetailCmtsItem2 = this.containerComments.get_Children().get_Item(i - 1) as TLDetailCmtsItem;
							tLDetailCmtsItem2.canvasCmtsLine.set_Visibility(1);
						}
					}
					this.containerComments.get_Children().RemoveAt(i);
					tLDetailCmtsItem.mClickDlg = null;
					TLDetailCmtsItem.PushOneItem(tLDetailCmtsItem);
					if (this.mBHasCmt && this.mBHasLike)
					{
						this.canvasCmtAndLikeLine.set_Visibility(0);
					}
					else
					{
						this.canvasCmtAndLikeLine.set_Visibility(1);
					}
				}
			}
		}
		public static TimelineDetailCtrl GetOneItem()
		{
			if (TimelineDetailCtrl.sTimelineDetailCtrl != null && TimelineDetailCtrl.sTimelineDetailCtrl.get_Count() != 0)
			{
				TimelineDetailCtrl timelineDetailCtrl = Enumerable.First<TimelineDetailCtrl>(TimelineDetailCtrl.sTimelineDetailCtrl);
				TimelineDetailCtrl.sDictUsedItems.set_Item(timelineDetailCtrl.mNItemId, timelineDetailCtrl);
				TimelineDetailCtrl.sTimelineDetailCtrl.RemoveAt(0);
				return timelineDetailCtrl;
			}
			TimelineDetailCtrl timelineDetailCtrl2 = new TimelineDetailCtrl();
			TimelineDetailCtrl.sDictUsedItems.set_Item(timelineDetailCtrl2.mNItemId, timelineDetailCtrl2);
			return timelineDetailCtrl2;
		}
		public static void PushOneItem(TimelineDetailCtrl item)
		{
			if (TimelineDetailCtrl.sDictUsedItems.ContainsKey(item.mNItemId))
			{
				item.setLikeCnt(0);
				TimelineDetailCtrl.sTimelineDetailCtrl.Add(TimelineDetailCtrl.sDictUsedItems.get_Item(item.mNItemId));
				item.mListDefaultCmts = null;
				TimelineDetailCtrl.sDictUsedItems.Remove(item.mNItemId);
			}
		}
		public static void PushOneItem(int nItemId)
		{
			if (TimelineDetailCtrl.sDictUsedItems.ContainsKey(nItemId))
			{
				TimelineDetailCtrl.sTimelineDetailCtrl.Add(TimelineDetailCtrl.sDictUsedItems.get_Item(nItemId));
				TimelineDetailCtrl.sDictUsedItems.Remove(nItemId);
			}
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/Plugin/Sns/Common/UI/TimelineDetailCtrl.xaml", 2));
			this.btnLayoutRoot = (Grid)base.FindName("btnLayoutRoot");
			this.imgHead = (UserHeadCtrl)base.FindName("imgHead");
			this.txtNickName = (NickNameButton)base.FindName("txtNickName");
			this.txtAction = (TextBlock)base.FindName("txtAction");
			this.richTxtIntro = (RichTextBox)base.FindName("richTxtIntro");
			this.paraIntro = (Paragraph)base.FindName("paraIntro");
			this.containerlPics = (Grid)base.FindName("containerlPics");
			this.txtSendTo = (EmojiTextEx)base.FindName("txtSendTo");
			this.containerExInfo = (StackPanel)base.FindName("containerExInfo");
			this.txtTime = (TextBlock)base.FindName("txtTime");
			this.txtLoc = (TextBlock)base.FindName("txtLoc");
			this.btnVisibility = (ClickableLayout)base.FindName("btnVisibility");
			this.imgVisiRangeTag = (Image)base.FindName("imgVisiRangeTag");
			this.btnDelete = (ClickableLayout)base.FindName("btnDelete");
			this.panelLikeAndCmt = (StackPanel)base.FindName("panelLikeAndCmt");
			this.gridCmtLikeBack = (Grid)base.FindName("gridCmtLikeBack");
			this.panelLike = (StackPanel)base.FindName("panelLike");
			this.mRichTxtLikes = (RichTextBox)base.FindName("mRichTxtLikes");
			this.mParaLikes = (Paragraph)base.FindName("mParaLikes");
			this.canvasCmtAndLikeLine = (Canvas)base.FindName("canvasCmtAndLikeLine");
			this.panelCmts = (StackPanel)base.FindName("panelCmts");
			this.containerComments = (StackPanel)base.FindName("containerComments");
			this.txtCantCmt = (TextBlock)base.FindName("txtCantCmt");
			this.panelResend = (ClickEffectGrid)base.FindName("panelResend");
			this.txtResend = (TextBlock)base.FindName("txtResend");
		}
	}
}
